package cn.tedu.charging.order.controller;


import cn.tedu.charging.common.pojo.JsonResult;
import cn.tedu.charging.order.pojo.param.OrderCreateParam;
import cn.tedu.charging.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("order")
@Api(tags = "订单模块")

public class OrderController {

    @Autowired
    private OrderService orderService;

    @ApiOperation("创建订单")
    @PostMapping("create")
    public JsonResult<String> createOrder(@RequestBody OrderCreateParam orderCreateParam){
        log.debug("创建订单-入参:{}", orderCreateParam);

        log.debug("创建订单-入参:{}", orderCreateParam);
        String orderNo = orderService.createOrder(orderCreateParam);
        log.debug("创建订单-入参:{},出参:{}", orderCreateParam, orderNo);

//        JsonResult<String> result = new JsonResult<>();
//        result.setData(orderNo);
//        result.setMessage("创建订单成功");
//        result.setCode(2000);
        JsonResult<String> result = JsonResult.ok(orderNo, "创建订单成功" );
        log.debug("创建订单-入参:{},出参:{}", orderCreateParam, result);
        return result;
    }

}
